import { DataTypes, Sequelize } from 'sequelize'
import { BaseModel, BaseModelAttribute } from './baseModel'
import { ModelUtils } from './modelUtils'
interface InvestmentAttribute extends BaseModelAttribute {
  code: string
  company: string
  startDate: Date
  principal: number
  returnRate: number
  type: string
  earnings: number
  endDate: Date
}
export class Investment extends BaseModel<InvestmentAttribute>{
  code: string
  company: string
  startDate: Date
  principal: number
  returnRate: number
  type: string
  earnings: number
  endDate: Date
}
export class InvestmentInit {
  static init(sequelizeInstance: Sequelize) {
    Investment.init(ModelUtils.appendPublicFields({
      code: { type: DataTypes.STRING, allowNull: false, comment: '编号' },
      company: { type: DataTypes.STRING, allowNull: false, comment: '公司' },
      startDate: { type: DataTypes.DATE, allowNull: false, comment: '开始日期' },
      principal: { type: DataTypes.DECIMAL, allowNull: false, comment: '本金' },
      returnRate: { type: DataTypes.DECIMAL, comment: '利率' },
      type: { type: DataTypes.STRING, allowNull: false, comment: '类型（1：固定利息，2：非固定利息）' },
      earnings: { type: DataTypes.DECIMAL, comment: '收益' },
      endDate: { type: DataTypes.DATE, comment: '预计结束日期' }
    }), ModelUtils.appendTablePublicProperties('investment', sequelizeInstance, '投资理财表'))
  }
}